#ifndef __QpwClient__
#define __QpwClient__

#include <QtCore/QObject>
#include <QtGui/QMenuBar>
#include <QyGLViewWidget.h>
#include <QpwNetwork.h>
#include <QpwGeometryDatabase.h>
#include <QpwStyleDatabase.h>
#include <QpwSubTypeDatabase.h>
#include "QpwLoginDialog.h"
#include "QpwRender.h"

class QpwPlayerController;

namespace QpwItems { class Decoration; };

class QpwClient : public QObject {
    Q_OBJECT
public:
    explicit QpwClient( QObject * parent = 0 );
    virtual ~QpwClient();

private slots:
    void on_actionNewGame_triggered();
    void on_actionJoinGame_triggered();
    void on_actionQuit_triggered();
    void on_client_datagramReceived( QyNet::AbstractDatagramEncoder * datagram );

private:
    bool readConfig();
    bool startGame();
    void createMenu();
    void timerEvent( QTimerEvent * event );
    QpwItems::Decoration * addObject( const QUuid & uuid, const QUuid & subType );

    QString rootDir,
            dataDirPath;
    quint16 port;
    QyGL::ViewWidget viewWidget;
    QpwNetwork::Client client;
    QpwRender render;
    int timerId;
    QMenuBar menuBar;
    QpwLoginDialog loginDialog;
    QpwGeometryDatabase geometryDatabase;
    QpwStyleDatabase styleDatabase;
    QpwSubTypeDatabase subTypeDatabase;
    QMap<QUuid,QpwItems::Decoration*> items;
    QpwPlayerController * playerController;


};

#endif//__QpwClient__
